package org.esky.mail;

import java.io.InvalidObjectException;
import java.io.ObjectStreamException;
import java.io.Serializable;

import org.esky.mail.MailSenderServerInfo;

/**
 * @author Jack.Xu
 * @ClassName: MailSenderInfo
 * @Description: 发送邮件需要使用的基本信息
 * @author: Jack.Xu
 * @date: 2013年10月15日 下午4:11:17
 */
public class MailSenderInfo extends MailSenderServerInfo{
	// 邮件发送者的地址
	private String fromAddress;
	// 邮件接收者的地址
	private String toAddress;
	// 邮件主题
	private String subject;
	// 邮件内容
	private String content;
	// 邮件内容格式
	private ContentType contentType;
	// 邮件附件的文件名
	private String[] attachFileNames;
	// 邮件的接收者，可以有多个
	private String[] receivers;
	// 邮件的抄送者，可以有多个
	private String[] ccs;
	// 邮件的密送者，可以有多个
	private String[] bccs;

	public String getFromAddress() {
		return fromAddress;
	}

	public void setFromAddress(String fromAddress) {
		this.fromAddress = fromAddress;
	}

	public String getToAddress() {
		return toAddress;
	}

	public void setToAddress(String toAddress) {
		this.toAddress = toAddress;
	}

	public String getSubject() {
		return subject;
	}

	public void setSubject(String subject) {
		this.subject = subject;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public ContentType getContentType() {
		return contentType;
	}

	public void setContentType(ContentType contentType) {
		this.contentType = contentType;
	}

	public String[] getAttachFileNames() {
		return attachFileNames;
	}

	public void setAttachFileNames(String[] attachFileNames) {
		this.attachFileNames = attachFileNames;
	}

	public static class ContentType implements Serializable {
		private static final long serialVersionUID = -7744878545198042698L;
		protected String type;

		protected ContentType(String type) {
			this.type = type;
		}

		public static final ContentType TEXT = new ContentType("text");
		public static final ContentType HTML = new ContentType("html");

		protected Object readResolve() throws ObjectStreamException {
			if (type.equals("text"))
				return TEXT;
			else if (type.equals("html"))
				return HTML;
			else
				throw new InvalidObjectException(
						"Attempt to resolve unknown RecipientType: " + type);
		}

		public String toString() {
			return type;
		}
	}
	
	public String[] getReceivers() {
		return receivers;
	}

	public void setReceivers(String[] receivers) {
		this.receivers = receivers;
	}

	public String[] getCcs() {
		return ccs;
	}

	public void setCcs(String[] ccs) {
		this.ccs = ccs;
	}

	public String[] getBccs() {
		return bccs;
	}

	public void setBccs(String[] bccs) {
		this.bccs = bccs;
	}
}
